const http = uni.$u.http
import { env } from '@/config.js';
let APIBASE_URL = env?.serviceDesk?.baseURL
if (env.hasChangEnv) {
	let serviceBaseURL = env.serviceBaseURL
	let apiEnv = uni.getStorageSync('apiEnv');
	if (apiEnv) {
		APIBASE_URL = serviceBaseURL[apiEnv]
	} else {
		APIBASE_URL = serviceBaseURL[env.env]
	}
}
//发送验证码
export function sendSmsCode(data) {
	return http.get('/app/sendCheckCode', {
		params: {
			...data
		}
	});
}

//验证码登录
export function smsCodeLogin(data) {
	return http.get('/app/loginPhoneAndCode', {
		params: {
			...data
		}
	});
}

//用户信息获取
export function userget(data) {
	return http.post('/auth/user/get', data);
}

export function getUsersByAgentId(isOnlyLeader) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		orgId
	} = userInfo;
	return http.get('/app/getUsersByAgentId', {
		params: {
			agentId: orgId,
			isOnlyLeader
		}
	});
}

export function getUserShowMenus(isOnlyLeader) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		userRoleId
	} = userInfo;
	return http.get('/pc/getUserShowMenus', {
		params: {
			userRole: userRoleId
		}
	});
}

// 获取客户咨询页面路径 
export function GetCustomerServicePath(params) {
	return uni.request({
		url: `${APIBASE_URL}/oneapp/helpdesk_rebot_qa`,
		method: "POST",
		data: {
			params: params
		}
	})
}
// 新增问题反馈
export function AddFeedBack(params) {
	return http.post('/api/question/insert', params)
}

// 获取管理员用户的ID获取所有人员信息
export function getUserByOrgId(data) {
	return http.get('/pc/getUsersByOrgId', {
		params: {
			...data
		}
	});
}

// 获取全部角色
export function getRole(data) {
	return http.get('/pc/getRoles', {
		params: {
			...data
		}
	});
}

// 修改用户角色
export function updateUserRole(data) {
	return http.get('/pc/updateUserRole', {
		params: {
			...data
		}
	});
}

// 修改用户账号启用停用
export function delUser(data) {
	return http.get('/pc/updateUserState', {
		params: {
			...data
		}
	});
}
/**
 *  获取smartbi的链接
 * @params {
 * 	brand: 'anneng or gfx'
 * 	type: '1 or 2'
 * }
 */
export function GetSmartbiPath(params) {
	return http.get('/api/bi/getOssToken', {
		params
	});
}


// 添加用户cid
export function changeCid(data) {
	return http.get('/app/updatePhoneUnipushCid', {
		params: {
			...data
		}
	})
}

// 更改用户推送状态
export function changePush(data) {
	return http.get('/app/updatePhoneIsRecvPush', {
		params: {
			...data
		}
	})
}
// 获取版本更新信息
export function getNewVersion(data) {
	return http.get('/tools/getAppVersion', {
		params: {
			...data
		}
	});
}
// 添加或更新手机版本信息
export function addAndChangeUserVersion(data) {
	return http.post('/tools/addPhoneVersion', data);
}
// 获取用户版本
export function getUserVersion(data) {
	return http.get('/tools/getPhoneVersion', {
		params: {
			...data
		}
	});
}

// 获取用户getBanner
export function getBanner(role) {
	return http.get(`/api/banner/getBanner?brand=1&role=${role}`)
}

